package com.mes.bac.backend.controller;

import com.mes.bac.backend.common.vo.R;
import com.mes.bac.backend.entity.SystemConfig;
import com.mes.bac.backend.service.ISystemConfigService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@Tag(name = "3. 系统配置", description = "管理全局系统参数")
@RestController
@RequestMapping("/api/config")
public class SystemConfigController {

    @Autowired
    private ISystemConfigService systemConfigService;

    @Operation(summary = "获取所有配置项")
    @GetMapping("/list")
    public R<List<SystemConfig>> list() {
        return R.success(systemConfigService.list());
    }

    @Operation(summary = "批量更新配置项")
    @PutMapping("/update")
    public R<Void> update(@RequestBody List<SystemConfig> configs) {
        systemConfigService.updateConfigs(configs);
        return R.successMessage("配置更新成功");
    }
}